package com.zzhrtech.wgzx_cityzen;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.zzhrtech.wgzx_cityzen.ui.me.LoginActivity;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by renxiangpeng on 16/7/20.
 */
public class GuideActivity extends BaseActivity {

    private ImageView loadImageView;
    private AlphaAnimation animation;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        //云通信
        //好友关系

        initView();

        new Timer().schedule(new TimerTask() {

            @Override
            public void run() {

                if (getCache().getAsString(keyUid) == null){
                    Intent intent = new Intent(GuideActivity.this, LoginActivity.class);
                    startActivityForResult(intent,3);
                    finish();
                }else {

                    Intent intent = new Intent(GuideActivity.this,MainActivity.class);
                    startActivity(intent);
                    finish();
                }

            }

        }, 3000);



    }


    private void initView() {
        loadImageView = (ImageView) findViewById(R.id.load_image);
        //透明度渐变动画（取值范围0.0完全不显示-1.0完全显示）
        animation = new AlphaAnimation(0.3f, 1.0f);
        //设置动画的持续时间
        animation.setDuration(1500);
        //将组件和动画进行关联
        loadImageView.setAnimation(animation);

        animation.setAnimationListener(new Animation.AnimationListener() {

            //动画启动的时候执行
            @Override
            public void onAnimationStart(Animation animation) {

            }

            //动画重复执行的时候执行
            @Override
            public void onAnimationEnd(Animation animation) {

            }

            //动画结束的时候执行
            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);// 必须要调用这句
    }
}
